#ES_IP请替换成自己的es的ip地址和端口
#$1  命令行第一个参数
ES_IP=es.$1:9200
 #获取系统版本信息
version=$(cat /proc/version)
if [[ $version =~ Ubuntu ]]; then
 echo "ubuntu系统，获取deb包"
 sudo curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.10.1-amd64.deb
 echo “获取成功，开始安装filebeat”
 dpkg -i filebeat-7.10.1-amd64.deb
 rm -rf filebeat-7.10.1-amd64.deb
 
elif [[ $version =~ centos ]]; then
 echo "centos系统"
 sudo curl -L -k -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.10.1-x86_64.rpm
 echo "获取成功，开始安装filebeat"
 sudo yum install -y filebeat-7.10.1-x86_64.rpm
 sudo rm -rf filebeat-7.10.1-x86_64.rpm
 
fi
echo "获取自定义配置文件"
echo "y" | mv settings/filebeat7.10.1.yml /etc/filebeat/filebeat.yml
sudo sed -i 's/es\.example\.com:9200/'$ES_IP'/g' /etc/filebeat/filebeat.yml
sudo service filebeat restart 
systemctl enable filebeat